#!/bin/sh /etc/rc.common

USE_PROCD=1

START=99
STOP=01

start_service() {
    procd_open_instance

    # Retry count would be reset to 0 after 3600 seconds.
    # Retry after 10 seconds.
    # Always retry.
    procd_set_param respawn 3600 10 0

    procd_set_param pidfile REPLACE_WITH_GG_LOADER_PID_FILE

    # Redirect stdout to system log.
    procd_set_param stdout 1

    # Redirect stderr to system log.
    procd_set_param stderr 1

    # We pass environment variables of Java here because Java may not be installed through opkg. If it's manually installed, we need to provide these variables.
    procd_set_param command /bin/sh -c "JAVA_HOME=\"REPLACE_WITH_GG_JAVA_HOME\" PATH=\"$PATH:REPLACE_WITH_GG_JAVA_HOME/bin\" exec /bin/sh REPLACE_WITH_GG_LOADER_FILE"

    procd_close_instance
}
